#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 1e6 + 10, M = 1e5 + 10;

int n;
int cnt[N];
int q[N];
int s[N];


int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    memset(cnt, 0, sizeof cnt);
    memset(s, 0, sizeof s);
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> q[i];
        cnt[q[i]] ++;
    }
    for(int i = 1; i < N; i ++){
        for(int j = i; j < N; j += i){
            s[j] += cnt[i];
        }
    }

    for(int i = 1; i <= n; i ++){
        cout << s[q[i]] - 1 << '\n';
    }


    return 0;
}